<template>
  <HomePanel title="新鲜好物" sub-title="新鲜出炉 品质靠谱" ref="target">
    <template #right>
      <XtxMore></XtxMore>
    </template>
    <template  #default>
      <ul ref="pannel" class="goods-list" v-if="list.length">

        <li v-for="item in list" :key="item.id">
          <RouterLink to="`/product/${item.id}`">
            <img v-imgLazy="item.picture"  alt="" />
            <!-- :src="item.picture" -->
            <p class="name">{{item.name}}</p>
            <p class="price">&yen;{{item.price}}</p>
          </RouterLink>
        </li>

        <!-- 占位 -->
        <!-- <template v-else>
            <li v-for="i in 4" :key="i">
            <XtxSkeleton  :width='306' :height='306'/>
            <XtxSkeleton  :width='280' :height='30' style="margin:15px 10px" />
            <XtxSkeleton  :width='60' :height='25' style='margin-left:40%'/>
            </li>
        </template> -->

        <!-- 占位 -->
      </ul>
       <ul v-else ref="pannel" class="goods-list">
        <li v-for="item in 4" :key="item">
            <XtxSkeleton :width="306" :height="406" bg="rgba(0,0,0,0.6)"></XtxSkeleton>
        </li>
        </ul>
    </template>

  </HomePanel>
</template>

<script>
import HomePanel from './home-panel'
import { findHomeNew } from '@/api/home'
import { useObserver } from '@/compositions/index'

export default {
  components: {
    HomePanel
  },
  setup () {
    return new Promise((resolve, reject) => {
      const { list, target } = useObserver(findHomeNew)
      resolve({ list, target })
    })
  }
}
</script>

<style scoped lang='less'>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
